package com.youngjun.user.service.impl;

import com.youngjun.user.mapper.FunctionInterfaceMapper;
import com.youngjun.user.pojo.domain.FunctionInterface;
import com.youngjun.user.pojo.dto.FunctionInterfaceDTO;
import com.youngjun.user.service.FunctionInterfaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FunctionInterfaceServiceImpl implements FunctionInterfaceService {

    @Autowired
    FunctionInterfaceMapper functionInterfaceMapper;

    @Override
    public FunctionInterfaceMapper getMapper() {
        return functionInterfaceMapper;
    }

    @Override
    public void create(FunctionInterfaceDTO dto) {
        for (Long interfaceId:dto.getInterfaceIds()) {
            FunctionInterface functionInterface = new FunctionInterface();
            functionInterface.setFunctionId(dto.getFunctionId());
            functionInterface.setInterfaceId(interfaceId);
            insert(functionInterface);
        }
    }

    @Override
    public void deleteWithLogicByFunctionId(Long functionId) {
        getMapper().deleteWithLogicByFunctionId(functionId);
    }

    @Override
    public void deleteWithLogicByInterfaceId(Long interfaceId) {
        getMapper().deleteWithLogicByInterfaceId(interfaceId);
    }

    @Override
    public void delete(Long functionId, Long interfaceId) {
        getMapper().delete(functionId,interfaceId);
    }


}